﻿// ***********************************************************************
// Assembly         : DonNicky.Common.NET4
// Author           : donnicky
// Created          : 11-26-2012
//
// Last Modified By : donnicky
// Last Modified On : 11-26-2012
// ***********************************************************************
using System;
using System.Globalization;
using System.IO;
using System.Windows.Data;

namespace DonNicky.Common.Converters
{
    /// <summary>
    /// Converts multiline string to its first line
    /// </summary>
    public class DropMultiLinesConverter : IValueConverter
    {
        /// <summary>
        /// Converts a value.
        /// </summary>
        /// <param name="value">The multiline string value produced by the binding source.</param>
        /// <param name="targetType">The type of the binding target property.</param>
        /// <param name="parameter">The converter parameter to use.</param>
        /// <param name="culture">The culture to use in the converter.</param>
        /// <returns>A converted value. If the method returns null, the valid null value is used.</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return new StringReader(value.ToString()).ReadLine();
        }

        /// <summary>
        /// Not implemented.
        /// </summary>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
